*******************************************************************************
clear all
set maxvar 30000
version 14
capture log close
set more off

****************************************************************************************************
* -----   Customize the paths and options:   ----- 
****************************************************************************************************
*cd  "Data\"

*
global MY_IN_PATH   "/Users/ben/Dropbox/RnD_tax_credit/ReStat_repl_package/Data"
global MY_OUT_PATH  "/Users/ben/Dropbox/RnD_tax_credit/ReStat_repl_package/Data"

*global MY_TEMP_PATH "..."

global MY_OUT_FILE  ${MY_OUT_PATH}out.dta
global MY_LOG_FILE  ${MY_OUT_PATH}cr_out.log


*global MY_TEMP_PATH "..."

*global MY_OUT_FILE  ${MY_OUT_PATH}out.dta
*global MY_LOG_FILE  ${MY_OUT_PATH}cr_out.log


*log using "${MY_LOG_FILE}", text replace
****************************************************************************************************
* import tax credit data
*************************************************************************************************
import delimited ${MY_IN_PATH}/RDusercost.txt, clear

gen nominal_rate = state_cred_highest_tier
gen effective_rate = rec_val_state_cred_highest_tier

sum nominal_rate effective_rate

gen rd_efr_hi = effective_rate
gen rd_nom_hi = nominal_rate

xtset fips year


foreach num of numlist 1/10 {
gen l`num'rd_efr_hi = l`num'.rd_efr_hi
gen l`num'rd_nom_hi = l`num'.rd_nom_hi
}

foreach num of numlist 1/10 {
gen f`num'rd_efr_hi = f`num'.rd_efr_hi
gen f`num'rd_nom_hi = f`num'.rd_nom_hi
}

save ${MY_OUT_PATH}/rd_tax_credit_det.dta, replace
